<%@ page language="java" import="java.util.*" pageEncoding="Utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>检查单管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/easyui/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${ctx }/resources/css/icon.css">
<link rel="stylesheet" type="text/css" href="${ctx }/resources/css/wu.css" />
<script type="text/javascript" src="${ctx }/resources/easyui/jquery.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/easyui/locale/easyui-lang-zh_CN.js"></script>
</head>

<body>
	 
	<!-- 查询条件开始 -->
	<div class="easyui-panel" data-options="title:'查询条件',iconCls:'icon-search'" style="width:100%;">
		<form id="searchFrm" method="get">
			<table width="100%" cellpadding="10" >
				<tr>
					<td width="33%">
					<input class="easyui-textbox" name="checkid"
							data-options="label:'检查单号:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
					<td width="33%"> 
					<input class="easyui-textbox" name="rentid"
							data-options="label:'出租单号:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
					<td width="33%">
					<input class="easyui-textbox" name="problem"
							data-options="label:'存在问题:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
				</tr>
				<tr>
					<td width="33%">
					<input class="easyui-datebox" name="startDate"
							data-options="label:'开始时间:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
					<td width="33%">
					<input class="easyui-datebox" name="endDate"
							data-options="label:'结束时间:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
					<td width="33%">
					<input class="easyui-textbox" name="checkdesc"
							data-options="label:'问题描述:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
				</tr>
				<tr>
					<td colspan="3" align="center">
						<a href="javascript:void(0)" class="easyui-linkbutton" onclick="doSearch()" data-options="iconCls:'icon-search'">查询</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#searchFrm').form('clear')" data-options="iconCls:'icon-reload'">重置</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<!-- 查询条件结束 -->
	 <div style="height: 2px"></div>
	 <!-- 数据表格开始 -->
    <table id="table" class="easyui-datagrid" style="width:100%;height:300px">
    </table>
	<div id="tb">
	<a href="javascript:void(0)" class="easyui-linkbutton" id="updateCheck" data-options="iconCls:'icon-edit',plain:true">修改出租单</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" id="exportCheck" data-options="iconCls:'icon-page-excel',plain:true">导出出租单</a>
	</div>
	<!-- 数据表格结束  -->
	
	<!-- 添加和修改用户的弹出层 开始 -->
	<div id="dlg" class="easyui-dialog" style="width:500px" data-options="closed:true,modal:true,border:'thin',buttons:'#dlg-buttons'">
        <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
            <div style="margin-bottom:10px">
                <input name="checkid" id="checkid" class="easyui-textbox" required="true" label="检查单号:" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="checkdate" class="easyui-datebox" required="true" label="检查日期:" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="problem" class="easyui-textbox" required="true" label="存在问题:" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="checkdesc"  class="easyui-textbox" required="true"  label="问题描述:" style="width:100%">
            </div>
             <div style="margin-bottom:10px">
                <input name="paymoney" class="easyui-numberbox" required="true"  label="赔付金额:" style="width:100%">
            </div>
             <div style="margin-bottom:10px">
                <input name="rentid" id="rentid" class="easyui-textbox" required="true"  label="出租单号:" style="width:100%">
            </div>
             <div style="margin-bottom:10px">
                <input name="opername" id="opername"  class="easyui-textbox" required="true"  label="操作员:" style="width:100%">
            </div>
        </form>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveCheck()" style="width:90px">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
    </div>
	
	<!-- 添加和修改用户的弹出层 结束-->

	<script type="text/javascript">
	//加载表格数据
	$("#table").datagrid({
		title:'出租单列表',
		singleSelect:true,
		collapsible:true,
        fitColumns:true,
        pagination:true,
        rownumbers:true,
        toolbar:'#tb',
        url:'${ctx}/check/loadAllCheck.action',
        columns:[[
                  {field:'checkid',title:'检查单号',align:'center',width:100},
                  {field:'checkdate',title:'检查日期',align:'center',width:100},
                  {field:'problem',title:'存在问题',align:'center',width:100},
                  {field:'checkdesc',title:'问题描述',align:'center',width:100},
                  {field:'paymoney',title:'赔付金额',align:'center',width:100},
                  {field:'rentid',title:'出租单号',align:'center',width:100},
                  {field:'opername',title:'操作员',align:'center',width:100}
              ]]
       
	});
		//查询
		function doSearch(){
			var params=$("#searchFrm").serialize();
			$("#table").datagrid({
				url:'${ctx}/check/loadAllCheck.action?'+params
			});
		};
		//打开修改的弹出层
		$("#updateCheck").click(function(){
			//得到当前行
			var row=$("#table").datagrid('getSelected');
			if(row){
				$("#dlg").dialog("open").dialog('setTitle','修改检查单');
				//表单数据装载
				$("#fm").form("load",row);
				//设置只读
				$("#checkid").textbox({readonly:true});
				$("#rentid").textbox({readonly:true});
				$("#opername").textbox({readonly:true});
			}else{
				$.messager.show({
					title:'提示',
					msg:'请选中操作行'
				});
			}
		});
		
		//保存
		function saveCheck(){
			$.messager.progress();	// 显示进度条
			$('#fm').form('submit', {
				url: "${ctx}/check/updateCheck.action",//数据提交地址 
				onSubmit: function(){
					var isValid = $(this).form('validate');//对表单里面的required:true和vailType的数据进行验证
					if (!isValid){
						$.messager.progress('close');	// 如果验证失败关闭进度条
					}
					return isValid;	//返回验证结果
				},
				success: function(obj){//如果提交成功之后回调的方法
					$.messager.progress('close');	// 关闭进度条
                    var result = eval('('+obj+')');//把obj的josn字符串转成js认识的json对象
					$.messager.show({
						title:'提示',
						msg:result.msg
					});
					$("#table").datagrid("reload");//刷新数据表格
					$("#dlg").dialog("close");//关闭弹出层
				}
			});
		}
		
	</script>
</body>
</html>